package com.cwz.controller;

import com.cwz.entity.Material;
import com.cwz.entity.MaterialInventoryRecord;
import com.cwz.param.MaterialHttpQueryParam;
import com.cwz.param.MaterialInventoryRecordHttpQueryParam;
import com.cwz.param.MaterialInventoryStatisticsParam;
import com.cwz.service.MaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Map;


/**
 * @author wenZhen
 * @create 2024-08-17 8:45
 */
@Slf4j
@RestController
@RequestMapping("/material")
public class MaterialController {

    @Resource
    private MaterialService materialService;


    @PostMapping("/save")
    public Map<String, Object> save(Material material, HttpSession session) {
        return materialService.save(material, session);
    }


    @PostMapping("/batch-import")
    public Map<String, Object> batchImport(MultipartFile file, HttpSession session) {
        return materialService.batchSave(file, session);
    }
    @GetMapping("/page")
    public Map<String,Object> page(MaterialHttpQueryParam param, HttpSession session) {
            return materialService.page(param, session);
    }
    @PostMapping("/disable")
    public Map<String, Object> disable(Material material, HttpSession session) {
        return materialService.disable(material, session);
    }
    @GetMapping("/detail")
    public Map<String, Object> detail(Integer id, HttpSession session) {
        return materialService.detail(id, session);
    }
    @PostMapping("/inventory")
    public Map<String, Object> inventory(MaterialInventoryRecord record, HttpSession session) {
        return materialService.inventory(record, session);
    }
    @GetMapping("/inventory-page")
    public Map<String,Object> inventoryPage(MaterialInventoryRecordHttpQueryParam param, HttpSession session) {
        return materialService.inventoryPage(param, session);
    }


    @GetMapping("/statistic")
    public Map<String,Object> statistic(MaterialInventoryStatisticsParam param,HttpSession session){
        return materialService.statistic(param,session);
    }


}
